package com.autumn.jvm.jvm;

/**
 * @author: Autumn
 * @describe:
 * @date: 2022/9/29
 * @modified By:
 */
public class User {
    private int id;
    private String name;

    static {
        System.out.println("====== load User ======");
    }

    public User() {
    }

    public User(int id, String name) {
        super();
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    protected void finalize() throws Throwable {
        OOMTest.list.add(this);
        System.out.println("关闭资源，userId=" + id + "即将被回收");
    }

    public void sout() {
        System.out.println("------ 自定义加载器加载类调用方法 ------");
    }
}
